package com.digitalchina.frame.core.spring;

public class ContainerManager {

	private static ContainerManager instance = new ContainerManager();

	private IContainerContext containerContext;

	private static boolean containerSetup = false;

	public static ContainerManager getInstance() {
		return instance;
	}

	private ContainerManager() {
		containerContext = null;
	}

	public static Object getComponent(String key) {
		return getInstance().getContainerContext().getComponent(key);
	}

	public static void autowireComponent(Object component) {
		getInstance().getContainerContext().autowireComponent(component);
	}

	public IContainerContext getContainerContext() {
		return containerContext;
	}

	public void setContainerContext(IContainerContext containerContext) {
		this.containerContext = containerContext;
	}

	public static void resetInstance() {
		instance = new ContainerManager();
		containerSetup = false;
	}

	public static boolean isContainerSetup() {
		return getInstance().containerContext != null && getInstance().containerContext.isSetup();
	}

}